<?php
namespace app\api\model;
use think\Model;
class Vegetables extends Model
{
    public function index()
    {   
       
    }
 
     public function getVegetables()
     {
	     	$rx = [ 
	            'zhuangtai' =>1,
	             'xlleixing'=>1,
	        ];

	        $xp = [
	             'zhuangtai' =>1,
	             'xlleixing' =>2,
	        ];
	        $dz =[
	            'zhuangtai'=>1,
	            'xlleixing'=>3,
	        ];

	        $vege = [
               'zhuangtai'=>1,
               'pzleixing'=>1,
           ];
          $meet = [
              'zhuangtai'=>1,
              'pzleixing'=>2,
          ];
          $beans = [
               'zhuangtai'=>1,
               'pzleixing'=>3,
          ];
          $oil = [
               'zhuangtai'=>1,
               'pzleixing'=>4,
          ];
           
        //热销类型
        $leixingone[0]  = model('Vegetables')
                             ->field("vid,url,vname,price,create_time,pzleixing")
                             ->where($rx)
                             ->select();
        //新品类型
        $leixingone[1]  = model('Vegetables')
                             ->field("vid,url,vname,price,create_time,pzleixing")
                             ->where($xp)
                             ->select();
        //打折类型
        $leixingone[2]  = model('Vegetables')
                             ->field("vid,url,vname,price,create_time,pzleixing")
                             ->where($dz)
                             ->select();
        //蔬菜水果类型
        $leixingtwo[0]  = model('Vegetables')
                             ->field("vid,url,vname,price,create_time,pzleixing")
                             ->where($vege)
                             ->select();
        //禽蛋肉食类型
        $leixingtwo[1]  = model('Vegetables')
                             ->field("vid,url,vname,price,create_time,pzleixing")
                             ->where($meet)
                             ->select();
        //熟食豆类型
        $leixingtwo[2]  = model('Vegetables')
                             ->field("vid,url,vname,price,create_time,pzleixing")
                             ->where($beans)
                             ->select();
        //米面粮油类型
        $leixingtwo[3]  = model('Vegetables')
                             ->field("vid,url,vname,price,create_time,pzleixing")
                             ->where($oil)
                             ->select();
        // $res =[$leixingone,$leixingtwo];
         $res['xlleixing_list'] = $leixingone;
         $res['pzleixing_list'] = $leixingtwo;
         return $res;
     }
         
    
    public  function VegetablesList()
    {
      $data = [
        'zhuangtai' =>1,
      ];
         return $vegetables = model('Vegetables')
                      ->alias("v")
                      ->join('gongyingshang g','g.gid=v.gid','LEFT')
                      ->field('v.vid,v.url,v.pzleixing,v.xlleixing,v.vname,v.price,g.gname')
                      ->where('v.zhuangtai',1)
                      ->select();
    } 
}